// util/Logger.java
package main.java.com.cinema.util;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Logger {
    private static final String LOG_FILE = "logs.txt";
    
    public static void log(String operationType, String description, String operator) {
        try (PrintWriter writer = new PrintWriter(new FileWriter(LOG_FILE, true))) {
            String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            writer.println("[" + timestamp + "] " + operationType + ": " + description + " (操作人: " + operator + ")");
        } catch (IOException e) {
            System.err.println("日志记录失败: " + e.getMessage());
        }
    }
}
